class CreateContactInfos < ActiveRecord::Migration
  def self.up
    create_table :contact_infos do |t|
      t.references :contact_field
      t.references :person
      t.text :value
      t.boolean :is_preferred_method
      t.timestamps
    end
    add_index(:contact_infos, [:person_id, :contact_field_id, :value], :unique => true)
    add_index(:contact_infos, [:person_id, :contact_field_id], :unique => false)
    add_index(:contact_infos, :person_id, :unique => false)
  end

  def self.down
    remove_index(:contact_infos, :column => [:person_id, :contact_field_id, :value])
    remove_index(:contact_infos, :column => [:person_id, :contact_field_id])
    remove_index(:contact_infos, :column => :person_id)
    drop_table :contact_infos
  end
end
